<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function handlerContainExpression(expression, key = 'contain') {  // /\.contain\([^)]*\)/g
            return expression.replace(/\.contain\([^)]*\)/g, (a,b,c) => {
                return `.${key}(${a.slice(key.length + 2, a.indexOf(')')).split(',').map(m => typeof m == 'number' ? m : `'${m}'`).join(',')})`
            })
        }
        

        console.log(handlerContainExpression(' asfa && 123,456.contain(TD_LSDEPT,2,asas,54) || 666.contain(a,b, c)  && asda  '))
    </script>
</body>
</html>